let array = [1, 2, 3, 4, 5, 6, 7]

function splitArray<T>(array: T[], range: number): Array<T[]> {
    let res: Array<T[]> = []
    for (let i = 0; i < array.length; i = i + range) {
        let temp: Array<T> = []
        for (let j = 0; j < range; j++) {
            let index = i + j
            if (index < array.length) {
                temp.push(array[index])
            }
        }
        res.push(temp)
    }
    return res
}

console.log(splitArray(array, 3))
